<?php
class bodyControl extendS baseControl{
	//显示内容  与显示回帖
	public function index(){
	     $newsModel = K("news");
		  $db=k('commentview');
	      $id=$_GET['id'];
	      $data=$db->where("nid=$id and stat=1")->all();
	      $this->assign("dabody",$data);
		  
	      if($newsModel->addClickCount($id)){
			$bookInfo = $newsModel->bodyshow($id);
			$this->assign('bookInfo',$bookInfo);
		    $pagebar = $this->contentPage($bookInfo[0]['body'],$id);
			$this->assign("pageBar", $pagebar);
			$this->display();
		}else{
			$this->error("增加次数失败！","",3);
		}
	}
//提交评论
 public function add_com(){
 	if(empty($_SESSION["user"]["uid"])){
 		$this->error("请登陆后在做评论","index/index");
 	  exit;
 	}
 	$uid=$_SESSION["user"]["uid"]; //用户ID
 	$nid=$_POST;
 	if($_POST['uid']!=$uid){
 		$this->error("非法提交");
 	}else{
      $db=M('comment');
      $_POST["ip"] = ip_get_client();
       $_POST["stat"] = 0;
 	  if(!$db->add($_POST)){
 	   $this->error('添加失败');
 	  }else{
 	  	 $this->success('评论成功');
 	  }
 	}
 	exit();
 
 }








}



?>